import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;

public class TView extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final byte SENSOR = 1;
	public static final byte GATEWAY = 2;
	public static final byte NETWORK = 3;
	public static final byte CONTROL = 4;
	public static final byte ABOUT = 5;
	
	private byte viewType;
	protected JInternalFrame frame;
	
	public TView(byte viewType, String Title) {
		frame = new JInternalFrame(Title, true, true, true, true);
		frame.add(this);
		frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		this.viewType = viewType;
	}
	
	public byte getViewType() { 
		return viewType; 
	}
	
	public JInternalFrame getFrame() { 
		return frame; 
	}
	
	public void showFrame() {
		frame.pack();
		frame.setVisible(true); 
	}
	
	public void showFrameAtRightOf(JInternalFrame fr) {
		int x = (int)fr.getLocation().getX();
		int y = (int)fr.getLocation().getY();
		int w = fr.getWidth();
		frame.setLocation(x+w+2, y);
		showFrame();
	}	
}
